<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Processing.js test of xmlElement,getChildren(), getName() </title>
	<script type="text/javascript" src="../../../processing.js"></script> 

</head>
<body>


	<script id="script" type="application/processing">
XMLElement xml;

void setup() {
  size(200, 200);
  xml = new XMLElement(this, "menu.xml");
  XMLElement[] kids = xml.getChildren("breakfast-menu/food");
  for (int i=0; i < kids.length; i++) {
    String site = kids[i].getName();
    println(site); 
  }
}

	</script>
<h1>XMLElement Test4 getChildren(): getChildren(), getName()</h1>
<h3>Source</h3><pre>
// The following short XML file called "sites.xml" is parsed 
// in the code below. It must be in the project's "data" directory
//&lt;?xml version="1.0"?&gt; 
// &lt;menu&gt; 
//  &lt;breakfast-menu&gt;
//    &lt;food&gt;
//      &lt;name id="0"&gt; Belgian Waffles&lt;/name&gt; 
//      &lt;price id="1"&gt; $5.95&lt;/price&gt;
//      &lt;description id="2"&gt; two of our famous Belgian Waffles with plenty of real maple syrup&lt;/description&gt; 
//      &lt;calories id="3"&gt; 650&lt;/calories&gt;
//    &lt;/food&gt; 
//      &lt;food&gt;
//      &lt;name id="0"&gt; Strawberry Belgian Waffles&lt;/name&gt; 
//      &lt;price id="1"&gt; $7.95&lt;/price&gt;
//      &lt;description id="2"&gt; light Belgian waffles covered with strawberrys and whipped cream&lt;/description&gt; 
//      &lt;calories id="3"&gt; 900&lt;/calories&gt;
//    &lt;/food&gt; 
//  &lt;/breakfast-menu&gt; 
// &lt;/menu&gt; 

XMLElement xml;

void setup() {
  size(200, 200);
  xml = new XMLElement(this, "menu.xml");
  XMLElement[] kids = xml.getChildren("breakfast-menu/food");
  for (int i=0; i < kids.length; i++) {
    String site = kids[i].getName();
    println(site); //prints food food
  }
}
</pre>
<canvas id="display" style="width:10;height:10;"></canvas>
</body>
</html>

